home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
UpTime Volume 1 #9
/
utv1n9s2.d64
/
fn edit
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-28
|
4KB
|
176 lines
100 rem function key editor
110 rem copyright (c) 1987
120 rem john m. campbell
130 rem all rights reserved
140 print "define function keys"
150 for i=1to8:df$(i)=chr$(222):nexti
160 ba=51000:ad=ba
170 a0=peek(655):a1=peek(656)
180 if ba+27<>a0+256*a1 then 220
190 print "function keys already defined"
200 print "type stop+restore keys then re-run"
210 goto 910
220 print "loading ml program into memory"
230 for i=1to82
240 read a
250 poke ad,a
260 ad=ad+1
270 next i
280 rem address-dependent code
290 vh=((ba+25)/256)and255:vl=(ba+25)-256*vh
300 poke ba+5,vl
310 poke ba+6,vh
320 wh=((ba+26)/256)and255:wl=(ba+26)-256*wh
330 poke ba+11,wl
340 poke ba+12,wh
350 sh=((ba+27)/256)and255:sl=(ba+27)-256*vh
360 poke ba+14,sl
370 poke ba+19,sh
380 ih=((ba+71)/256)and255:il=(ba+71)-256*ih
390 poke ba+53,il
400 poke ba+54,ih
410 th=((ba+82)/256)and255:tl=(ba+82)-256*th
420 poke ba+58,tl
430 poke ba+59,th
440 poke ba+72,vl
450 poke ba+73,vh
460 gosub 1310:rem check for default file
470 fk=0:gosub 1740:rw=20:cl=0:gosub 1680
480 fk=0:input"number of key to define";fk
490 gosub 1780
500 if fk=0 then 620
510 if fk<0 or fk>8 then print "invalid function key number":goto 470
520 rem prompt for string
530 a$=df$(fk):if a$="" then a$=chr$(222)
540 gosub 1740:rw=20:cl=0:gosub 1680
550 print "new string (def="+a$+")? ";
560 gosub 1010:rem process inputs
570 rw=8+fk:cl=21:gosub 1680
580 print " "
590 rw=8+fk:cl=21:gosub 1680
600 print df$(fk)
610 goto 470
620 rem end processing
630 print "writing fn key definitions into memory"
640 for i=1to8
650 ll=len(df$(i))
660 for j=1to11
670 if j=ll+1 then a=0:goto 720
680 if j>ll then a=32:goto 720
690 a=asc(mid$(df$(i),j,1))
700 if a=95 then a=13
710 if a=222 then a=0:ll=0
720 poke ad,a:ad=ad+1
730 next j
740 next i
750 input "create default file (y/n)";a$
760 if a$<>"y" then 880
770 print#15,"s0:fn defs"
780 open 3,8,3,"0:fn defs,s,w"
790 input#15,en,em$,et,es
800 if en<>0 then print "unable to create default file":goto 860
810 print "writing default values"
820 for i=1to8
830 print#3,df$(i)
840 rem print "fn key";i;"=";df$(i)
850 nexti
860 close3
870 gosub 1540
880 print "activating function keys"
890 sys ba
900 close15
910 end
920 data 120,173,143,2,141,0,0,173,144,2
930 data 141,0,0,169,0,141,143,2,169,0
940 data 141,144,2,88,96,0,0,166,203
950 data 228,197,240,38,224,3,144,34
960 data 224,7,176,30,173,141,2,106
970 data 144,5,138,24,105,4,170,188,0,0
980 data 162,0,185,0,0,240,9,230,198
990 data 157,119,2,232,200,208,242
1000 data 108,0,0,66,0,22,44,77,11,33,55
1010 rem get input string
1020 ll=0:aa$="":cs=0:print chr$(114);
1030 poke 212,0:rem quote mode off
1040 get a$:a=asc(a$+chr$(0)):if a=0 then gosub 1260:goto 1040
1050 if a=20 and ll=0 then 1040
1060 if a=13 then print chr$(157)chr$(32):goto 1240
1070 if a<>20 then 1130
1080 rem process delete
1090 ll=ll-1
1100 aa$=mid$(aa$,1,ll)
1110 print chr$(157)chr$(32)chr$(157)a$chr$(114);:cs=1
1120 goto 1040
1130 if ll=10 then 1230
1140 rem add character to string
1150 aa$=aa$+a$
1160 ll=ll+1
1170 print chr$(157)chr$(32)chr$(157)a$chr$(114);:cs=1
1180 if a=34 then poke 212,0
1190 if a<>222 then 1040
1200 rem null string
1210 print chr$(157)chr$(32):print"fn key definition deleted"
1220 goto 1240
1230 print chr$(157)chr$(32):print "exceeded 10-character maximum"
1240 if ll<>0 then df$(fk)=aa$
1250 return
1260 rem cursor control
1270 if cs=0 then print chr$(157)chr$(114);
1280 if cs=10 then cs=-10:print chr$(157)chr$(32);
1290 cs=cs+1
1300 return
1310 rem open file and read defaults
1320 print "searching for default file"
1330 open 15,8,15,"i"
1340 open 2,8,2,"0:fn defs,s,r"
1350 input#15,en,em$,et,es
1360 if en<>0 then print "no default definitions found":goto 1520
1370 print "reading default values"
1380 for i=1to8
1390 df$(i)=""
1400 get#2,a$
1410 if a$=chr$(13) then 1440
1420 df$(i)=df$(i)+a$
1430 goto 1400
1440 next i
1450 print chr$(147)
1460 rw=5:cl=10:gosub 1680
1470 print "function key editor"
1480 for i=1 to 8
1490 rw=8+i:cl=10:gosub 1680
1500 print "fn key";i;"= ";df$(i)
1510 next i
1520 close 2
1530 return
1540 rem store load file
1550 print#15,"s0:fn keys"
1560 input#15,en,em$,et,es
1570 open 2,8,1,"0:fn keys,p,w"
1580 input#15,en,em$,et,es
1590 bh=(ba/256)and255
1600 bl=ba-256*bh
1610 print#2,chr$(bl);
1620 print#2,chr$(bh);
1630 for i=0to168
1640 print#2,chr$(peek(ba+i));
1650 nexti
1660 close2
1670 return
1680 rem set cursor to (rw,cl)
1690 poke 781,rw
1700 poke 782,cl
1710 poke 783,0
1720 sys 65520 : rem call kernal plot routine
1730 return
1740 rem clear prompt line
1750 rw=20:cl=0:gosub 1680
1760 print " "
1770 return
1780 rem clear message line
1790 rw=21:cl=0:gosub 1680
1800 print " "
1810 rw=22:cl=0:gosub 1680
1820 print " "
1830 rw=22:cl=0:gosub 1680
1840 return